//
//  TypeViewController.m
//  GiftNotes
//
//  Created by wsh on 15/8/11.
//  Copyright (c) 2015年 wsh. All rights reserved.
//

//  该页面时分类的选择页面


#import "TypeViewController.h"
#import "Screen.h"
#import "AttackViewController.h"
#import "GiftViewController.h"


@interface TypeViewController ()
@property (nonatomic, strong) UISegmentedControl *segment;
@property (nonatomic, strong) AttackViewController *attackVC;
@property (nonatomic, strong) GiftViewController *giftVC;


@end




@implementation TypeViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    [self createSegmentCotroller];
    

    
}








#pragma mark --- 创建segmentcontroller和被控制的两个子视图
- (void)createSegmentCotroller{

    self.navigationController.navigationBar.barTintColor = [UIColor orangeColor];
    
    _segment = [[UISegmentedControl alloc] initWithItems:@[@"攻略",@"礼物"]];
    _segment.selectedSegmentIndex = 0;
    _segment.bounds = CGRectMake(0, 0, SCREEN_WIDTH / 2.0, 30);
    [_segment addTarget:self action:@selector(segmentAction:) forControlEvents:UIControlEventValueChanged];
    
    self.navigationItem.titleView = _segment;
    

    _giftVC = [[GiftViewController alloc] init];
    _giftVC.view.frame = CGRectMake(0, 40, SCREEN_WIDTH, SCREEN_HEIGHT - 40);
    [self.view addSubview:_giftVC.view];
    
    _attackVC = [[AttackViewController alloc] init];
    _attackVC.view.frame = CGRectMake(0, 40, SCREEN_WIDTH, SCREEN_HEIGHT - 40);
    [self.view addSubview:_attackVC.view];
    
    
    
    
    
}






#pragma mark --- action
- (void)segmentAction:(UISegmentedControl *)sender{
    if (sender.selectedSegmentIndex == 0) {
        [self.view bringSubviewToFront:_attackVC.view];
    } else {
        [self.view bringSubviewToFront:_giftVC.view];
    }
}




@end
